package com.demo;

/**
 * 懒汉(线程安全)
 * @author ytj
 * @date 2022/2/21
 */
public class Single2 {
    private static Single2 instance;

    private Single2(){

    }

    public synchronized static Single2 getInstance(){
        if(instance!=null){
            return instance;
        }
        instance=new Single2();
        return instance;
    }
}
